﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Media;
using WPF_GUI.Commanding;
using System.Windows.Input;

namespace WPF_GUI.ViewModels
{
    public class ColorSchemeWindowViewModel : ViewModelBase
    {
        private Window _colorSchemeWindow;
        private ObservableCollection<string> _colorNames = new ObservableCollection<string>();
        private string _mapBackgroundColor;
        private string _taxiwaysColor;
        private string _runwaysColor;
        private string _planeUnselectedOutlineColor;
        private string _planeUnselectedFillColor;
        private string _planeSelectedOutlineColor;
        private string _planeSelectedFillColor;
        private string _selectedRouteColor;

        public ColorSchemeWindowViewModel()
        {
            _mapBackgroundColor = "#FF00617A";
            _taxiwaysColor = "#FF3F3837";
            _runwaysColor = "Black";
            _planeUnselectedOutlineColor = "White";
            _planeUnselectedFillColor = "White";
            _planeSelectedOutlineColor = "Chartreuse";
            _planeSelectedFillColor = "Chartreuse";
            _selectedRouteColor = "#FFF9A400";

            _colorNames.Add("Black");
            _colorNames.Add("Red");
            _colorNames.Add("Blue");
            _colorNames.Add("Gray");
            _colorNames.Add("Green");
            _colorNames.Add("White");
            _colorNames.Add("Yellow");
            _colorNames.Add("Chartreuse");
            _colorNames.Add("#FFF9A400");
            _colorNames.Add("#FFFFEF00");
            _colorNames.Add("#FF00ADFF");
            _colorNames.Add("#FF00C200");
            _colorNames.Add("#FF00617A"); // Blue-Green
            _colorNames.Add("#FF3F3837"); // Dark Gray

            if (!IsDesignTime)
            {
                _colorSchemeWindow = new ColorSchemeWindow();
                _colorSchemeWindow.DataContext = this;
                //_colorSchemeWindow.Show();
            }
        }

        public ObservableCollection<string> ColorNames
        {
            get
            {
                return _colorNames;
            }

            set
            {
                if (_colorNames != value)
                {
                    _colorNames = value;
                    OnPropertyChanged("ColorNames");
                }
            }
        }

        public string MapBackgroundColor
        {
            get
            {
                return _mapBackgroundColor;
            }

            set
            {
                if (_mapBackgroundColor != value)
                {
                    _mapBackgroundColor = value;
                    Object color = ColorConverter.ConvertFromString(_mapBackgroundColor);

                    if (color != null)
                    {
                        OnPropertyChanged("MapBackgroundColor");
                    }
                }
            }
        }

        public string TaxiwaysColor
        {
            get
            {
                return _taxiwaysColor;
            }

            set
            {
                if (_taxiwaysColor != value)
                {
                    _taxiwaysColor = value;

                    Object color = ColorConverter.ConvertFromString(_taxiwaysColor);

                    if (color != null)
                    {
                        OnPropertyChanged("TaxiwaysColor");
                    }
                }
            }
        }

        public string RunwaysColor
        {
            get
            {
                return _runwaysColor;
            }

            set
            {
                if (_runwaysColor != value)
                {
                    _runwaysColor = value;

                    Object color = ColorConverter.ConvertFromString(_runwaysColor);

                    if (color != null)
                    {
                        OnPropertyChanged("RunwaysColor");
                    }
                }
            }
        }

        public string PlaneUnselectedOutlineColor
        {
            get
            {
                return _planeUnselectedOutlineColor;
            }

            set
            {
                if (_planeUnselectedOutlineColor != value)
                {
                    _planeUnselectedOutlineColor = value;

                    Object color = ColorConverter.ConvertFromString(_planeUnselectedOutlineColor);

                    if (color != null)
                    {
                        OnPropertyChanged("PlaneUnselectedOutlineColor");
                    }
                }
            }
        }

        public string PlaneUnselectedFillColor
        {
            get
            {
                return _planeUnselectedFillColor;
            }

            set
            {
                if (_planeUnselectedFillColor != value)
                {
                    _planeUnselectedFillColor = value;

                    Object color = ColorConverter.ConvertFromString(_planeUnselectedFillColor);

                    if (color != null)
                    {
                        OnPropertyChanged("PlaneUnselectedFillColor");
                    }
                }
            }
        }

        public string PlaneSelectedOutlineColor
        {
            get
            {
                return _planeSelectedOutlineColor;
            }

            set
            {
                if (_planeSelectedOutlineColor != value)
                {
                    _planeSelectedOutlineColor = value;

                    Object color = ColorConverter.ConvertFromString(_planeSelectedOutlineColor);

                    if (color != null)
                    {
                        OnPropertyChanged("PlaneSelectedOutlineColor");
                    }
                }
            }
        }

        public string PlaneSelectedFillColor
        {
            get
            {
                return _planeSelectedFillColor;
            }

            set
            {
                if (_planeSelectedFillColor != value)
                {
                    _planeSelectedFillColor = value;

                    Object color = ColorConverter.ConvertFromString(_planeSelectedFillColor);

                    if (color != null)
                    {
                        OnPropertyChanged("PlaneSelectedFillColor");
                    }
                }
            }
        }

        public string SelectedRouteColor
        {
            get
            {
                return _selectedRouteColor;
            }

            set
            {
                if (_selectedRouteColor != value)
                {
                    _selectedRouteColor = value;

                    Object color = ColorConverter.ConvertFromString(_selectedRouteColor);

                    if (color != null)
                    {
                        OnPropertyChanged("SelectedRouteColor");
                    }
                }
            }
        }
    }
}
